﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using BALayer;

namespace PGBT
{
    public partial class DanhMucTraHang : Form
    {
        private GiaoDich db = null;
        private DataSet ds = null;
        private BindingSource bs = null;

        public DanhMucTraHang()
        {
            InitializeComponent();
            db = new GiaoDich();
        }

        private void DanhMucTraHang_Load(object sender, EventArgs e)
        {
            ds = db.DanhSachTraHang();
            cbMaTraHang.DataSource = ds.Tables[0];
            cbMaTraHang.DisplayMember = "matrahang";
        }

        private void cbMaTraHang_SelectedIndexChanged(object sender, EventArgs e)
        {
            bs = new BindingSource();
            bs.DataSource = ds;
            bs.Filter = "matrahang='" + ds.Tables[0].Rows[cbMaTraHang.SelectedIndex].ItemArray[0] + "'";
            dgvTraHang.DataSource = bs;
            dgvTraHang.AutoResizeColumns();
        }
    }
}
